<script type="text/javascript" src="/js/bootstrap-modal.js"></script>
<div id="tuizhi" class="modal hide fade">
	<div class="modal-header">
	<a href="#" class="close">&times;</a>
	发送职位邀请
	</div>
	<div class="modal-body">
	<ul class="tabs">
		<li class="active"><a href="#">新浪微博</a></li>
		<li><a href="#">腾讯微博</a></li>
	</ul>
	<div id="un-login" class="alert-message warning hide">
	<a class="close" href="#">×</a>
	<p>你还没有登录，<a href="WB2.login(function() { $('#un-login').hide(); });">点击这里</a>先登录才能继续发送职位邀请。</p>
	</div>
	<form action="" class="form-stacked">
		<div class="clearfix">
		<label for="job-status"></label>
		<div class="input">
			<textarea class="span8" id="job-status" name="job-status" rows="3"></textarea>
			<div class="action" style="padding:5px 0">
			<a id="btnSelect" href="javascript:selectPeople();" class="btn">选择好友</a>
            <a id="btnSend" href="" class="btn primary">发送邀请</a>&nbsp;
            <span id="action-msg" style="margin-left:10px"></span>
			</div>
		</div>
		</div>
	</form>
	<div id="selectedPeople"></div>
	</div>
	<div class="modal-footer">
	</div>
</div>
<script type="text/javascript">
    function checkCount(input,box) {
        var c = 140 - $(input).val().length;
        var msg;
        if (c >= 0) {
            msg = "还可以输入" + c + "字";
            $(box).removeClass("notice").addClass("success").html(msg);
        }
        else {
            msg = "已超出" + Math.abs(c) + "字";
            $(box).removeClass("success").addClass("notice").html(msg);
        }
    }

	function tuizhi(job) {
		var opt = {"backdrop":"static", "keyboard": "true"};
		$("#tuizhi").modal(opt, function() {
        });
        $("#job-status").val(job.company + "招聘" + job.title).keyup(function() {
            checkCount($("#job-status"),$("#action-msg"));
        });
        checkCount($("#job-status"),$("#action-msg"));
	}

    function setSelected(data) {
		var html = [], text = [];
		html.push("<ul class='media-grid'>");
		for (var i = 0; i < data.length; i++) {
			html.push("<li><a href='#'><img class='thumbnail' src='");
			html.push(data[i].img);
			html.push("' alt='");
			html.push(data[i].name);
			html.push("'></a>");
            //html.push(data[i].name);
            html.push("</li>");

            text.push("@" + data[i].name);
		}
		html.push("</ul>");
		$("#selectedPeople").html(html.join(''));
        $("#job-status").val($("#job-status").val() + " " + text.join(' '));
        checkCount($("#job-status"),$("#action-msg"));
    }

	function selectPeople() {
		WB2.anyWhere(function(W){
			W.widget.selector({
				id : "btnSelect",
				title: "选择好友",
				callback : setSelected
			});	
		});
        $("#tsina_selector_box").css("z-index", "12000");
	}
</script>
<script src=" http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=1138439236" type="text/javascript" charset="utf-8"></script>
